import { Alova } from '@/utils/http/alova/index';

// 股道停车信息数据结构
interface TrackParkingInfo {
  id: string;
  trackId: string;
  groupId: string;
  groupName: string;
  orgId: string;
  stationId: string;
  carriageNumber: number;
  createTime?: string;
  updateTime?: string;
}

// 分页查询参数
interface TrackParkingPageParams {
  currentPage: number;
  pageSize: number;
  trackId?: string;
  groupId?: string;
  orgId?: string;
  stationId?: string;
}

// 分页返回结果
interface TrackParkingPageResult {
  records: TrackParkingInfo[];
  total: number;
  currentPage: number;
  pageSize: number;
}

const baseApi = '/web/projTrackParking';

/**
 * 分页查询股道停车信息
 */
export function getTrackParkingList(params: TrackParkingPageParams) {
  return Alova.Post<InResult<TrackParkingPageResult>>(baseApi + '/page', { params });
}

/**
 * 获取所有股道停车信息
 */
export function getAllTrackParking(params: {
  trackId?: string;
  groupId?: string;
  orgId?: string;
  stationId?: string;
}) {
  return Alova.Post<InResult<TrackParkingInfo[]>>(baseApi + '/all', { params });
}

/**
 * 根据条件获取股道停车信息
 */
export function getParkingByTrackId(params: { trackId?: string; groupId?: string }) {
  return Alova.Post<InResult<TrackParkingInfo[]>>(baseApi + '/getTrackParking', { params });
}

/**
 * 添加股道停车信息
 */
export function addTrackParking(params: Partial<TrackParkingInfo>) {
  return Alova.Post<InResult<TrackParkingInfo>>(baseApi + '/add', { params });
}

/**
 * 更新股道停车信息
 */
export function updateTrackParking(params: TrackParkingInfo) {
  return Alova.Post<InResult<TrackParkingInfo>>(baseApi + '/update', { params });
}

/**
 * 删除股道停车信息
 */
export function removeTrackParking(params: { id: string }) {
  return Alova.Post<InResult<boolean>>(baseApi + '/remove', { params });
}
